﻿using System.Collections.Generic;
using System.Data;

namespace CoreEx.Database.Query.Expressions
{
    /// <summary>
    /// Represents the result of translating a <see cref="DbExpression"/> tree.
    /// </summary>
    public class DbTranslateResult
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DbTranslateResult"/> class.
        /// </summary>
        /// <param name="sql">The generated SQL statement.</param>
        /// <param name="parameters">A <see cref="List{T}"/> of <see cref="IDataParameter"/> instances that are referenced in the query.</param>
        public DbTranslateResult(string sql, IEnumerable<IDataParameter> parameters)
        {
            Sql = sql;            
            Parameters = new List<IDataParameter>(parameters);
        }
        
        /// <summary>
        /// Gets or sets a <see cref="IList{T}"/> that contains the 
        /// <see cref="IDataParameter"/> instances that has been created for constant expressions.
        /// </summary>
        public IList<IDataParameter> Parameters { get; private set; }

        /// <summary>
        /// Gets the Sql statement that has been created from a <see cref="DbExpression"/> tree.
        /// </summary>
        public string Sql { get; private set; }        
    }
}
